package com.bw.mallshop.mvvm.model;

import com.bw.common.entity.BaseEntity;
import com.bw.common.mvvm.model.BaseModel;
import com.bw.common.network.HttpType;
import com.bw.common.network.RetrofitFactory;
import com.bw.mallshop.entity.OrderEntity;
import com.bw.mallshop.entity.PayEntity;
import com.bw.mallshop.entity.PayOrderEntity;
import com.bw.mallshop.entity.SubOrderEntity;
import com.bw.mallshop.repository.ApiService;

import java.util.Map;

import io.reactivex.Observable;

/**
 * 确认订单界面
 *
 * */
public class ConfirmOrderModel extends BaseModel {

    //获取订单详情
    public Observable<BaseEntity>requestOrderDetails(Map<String,Object>parames){
        Observable<OrderEntity>observable = RetrofitFactory.factory(HttpType.TOKENSIGN)
                .createRetrofit().create(ApiService.class)
                .requestFindIdOrder(createBody(parames));
        return changeObservable(observable);
    }
    //确认订单
    public Observable<BaseEntity>requestConfirmOrder(Map<String,Object>parames){
        Observable<SubOrderEntity>observable = RetrofitFactory.factory(HttpType.TOKEN)
                .createRetrofit().create(ApiService.class)
                .requestSubOrder(createBody(parames));
        return changeObservable(observable);
    }
    //获取支付信息
    public Observable<BaseEntity>requestGetPay(Map<String,Object>parames){
        Observable<PayEntity>observable=RetrofitFactory.factory(HttpType.TOKENSIGN)
                .createRetrofit().create(ApiService.class)
                .requestPaySina(createBody(parames));
        return changeObservable(observable);
    }
    //确认支付成功
    public Observable<BaseEntity>requestConfirmPay(Map<String,Object>parames){
        Observable<PayOrderEntity>observable=RetrofitFactory.factory(HttpType.TOKENSIGN)
                .createRetrofit().create(ApiService.class)
                .requstPayOrder(createBody(parames));
        return changeObservable(observable);
    }
}
